package cn.edu.dgut.xhx.covid.web;

import cn.edu.dgut.xhx.covid.pojo.CovidPerson;
import cn.edu.dgut.xhx.covid.pojo.dto.CovidQueryDTO;
import cn.edu.dgut.xhx.covid.service.CovidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class CovidController {

    @Autowired
    private CovidService covidService;

    @GetMapping("/getList")
    public Page<CovidPerson> getList(@ModelAttribute CovidQueryDTO covidQueryDTO) {

        System.out.println(covidQueryDTO);
        Pageable pageable = PageRequest.of(covidQueryDTO.getPage(), covidQueryDTO.getSize());
        return covidService.getList(covidQueryDTO, pageable);
    }


}
